import React, {Component} from 'react';
import './index.less'
import GoIn from './GoIn'
import Reg from './Reg'
import Notice from "../../components/Notice";
import { Tabs,PageHeader } from 'antd';
const { TabPane } = Tabs;

class Login extends Component {
    render() {
        return (
            <div className='loginAndReg'>
                <PageHeader
                    className="site-page-header loginHeader"
                    onBack={() => this.props.history.go(-1)}
                    title="登录&注册"
                />
                <div className="container">
                    <Tabs defaultActiveKey="1" size='large' className='tabs'>
                        <TabPane tab="登录" key="1" className='tab1'>
                            <GoIn/>
                        </TabPane>
                        <TabPane tab="注册" key="2">
                            <Reg/>
                        </TabPane>
                    </Tabs>
                </div>
            </div>
        );
    }
    componentDidMount() {
        //当组件挂载时判断是否已经登录
        if(sessionStorage.getItem('userId')){
            Notice('info','您已登录','请勿重复登录');
            this.props.history.replace('/mall/home')
        }
    }
}

export default Login;